//welcome
function welcome(){
	var tNow = new Date();
	var iHour = tNow.getHours();
	var sWelcome;
	if(iHour == 23||iHour < 1){sWelcome='午夜';}
	else if(iHour <  6){sWelcome='凌晨';}
	else if(iHour <  8){sWelcome='早晨';}
	else if(iHour < 11){sWelcome='上午';}
	else if(iHour < 13){sWelcome='中午';}
	else if(iHour < 17){sWelcome='下午';}
	else if(iHour < 19){sWelcome='傍晚';}
	else{sWelcome='晚上';}
	sWelcome += '好!';
	document.write(sWelcome);
}

function checkCookie(){
	var sCookieValue1 = getCookie('NTES_SESS');
	if(sCookieValue1){
		var sCookieValue2 = getCookie('NETEASE_SSN'); 
		if (sCookieValue2){
			window.location="/Main.jsp?username="+sCookieValue2;
		}
	}
	//$('username').focus();
}

function checkCookie2(){
	 var sCookieValue2 = getCookie('NETEASE_SSN'); 
	 if( sCookieValue2 ){
	 	if(sCookieValue2.indexOf('@') == -1)
	 	 	sCookieValue2 += "@163.com";
		 document.getElementById("username").value = sCookieValue2 ;
		 window.setTimeout("document.getElementById('password').focus();", 50)  ;
	 }
	 else
	    window.setTimeout("document.getElementById('username').focus();", 50)  ;
}

function lastLoginUserTip(){
	 var sCookieValue = getCookie('NETEASE_SSN'); 
	 
	 if( sCookieValue ){
	 	 if(sCookieValue.indexOf('@') == -1)
	 	 	sCookieValue += "@163.com";
		 document.getElementById("lastuser").textContent = "温馨提示：本机上次登录的通行证用户名是：" + sCookieValue ;
		 document.getElementById("lastuser").innerText = "温馨提示：本机上次登录的通行证用户名是：" + sCookieValue ;
	 }
}

function getCookie(name){
    var cookiestr,reg,res,pos;
    cookiestring    =       new String(document.cookie);
    reg             =       new RegExp(name + '=[^;]*','i');
    tmp             =       cookiestring.match(reg);
    if(tmp == null){return false;}
    res             =       tmp[0];
    chr             =       "=";
    pos             =       res.indexOf(chr);
    return res.substring(pos+1);
}

function checkUsername(username) {
		//return /^[a-zA-Z\d\.\@\-_]+$/.test(username);
	 	var pos = username.indexOf("@");
	 	if(pos == -1)
	 		return username.length > 0;
	 	else{
	 		var ssn = username.substring(0,pos);
	 		return ssn.length > 0;
	 		
	 	}
	 	
	}
function checkdata() {
	var username = document.getElementById("username").value;
	if(!checkUsername(username)) {
		document.getElementById("eHint").innerHTML="\请您输入正确的用户名<br />";
        document.getElementById("username").focus();
		return false;
	}
	if( document.getElementById("password").value.length<1 || document.getElementById("password").value.length>20 ) {
		document.getElementById("eHint").innerHTML="\请您输入正确的密码<br />";
        document.getElementById("password").focus() ;
		return false;
	}
}

var load2=false;
var load4=false;
var load3=false;

function showDiv(obj,num,len)
{
  var iSetID="i"+obj+num;
  if ( num==2 && !load2){
     try{document.getElementById(iSetID).src="http://news.163.com/special/0001127H/regnews.html"}catch(e){};
	 if(obj == 'ntes'){load2=true;}
  }else if ( num==3 && !load3){
     try{document.getElementById(iSetID).src="http://money.163.com/special/00251MNR/regmoney.html"}catch(e){};
     if(obj == 'ntes'){load3=true;}
  }else if ( num==4 && !load4){
     try{document.getElementById(iSetID).src="http://blog.163.com/openentry/fromurs/albummsg.do"}catch(e){};
      if(obj == 'ntes'){load4=true;}
  }
 for(var id = 1;id<=len;id++)
 {
  var setID=obj+id;
  var setnavID=obj+"nav"+id;
  if(id==num){
  	try{document.getElementById(setID).style.display="block"}catch(e){};
  	try{document.getElementById(setnavID).className="active"}catch(e){};
  }else{
  	try{document.getElementById(setID).style.display="none"}catch(e){};
  	try{document.getElementById(setnavID).className=""}catch(e){};
  }
 }  
}


 barColors = new Array(4);
 barColors[0] = "#cccccc";
 barColors[1] = "#ff0000";
 barColors[2] = "#ff6600";
 barColors[3] = "#008000";
 function DrawBar(level) 
 {
   var bar1 = document.getElementById('levelBar1');
   var bar2 = document.getElementById('levelBar2');
   var bar3 = document.getElementById('levelBar3');
   var fontColor = document.getElementById('levelcolor');
   if (level == 3) 
   {
     bar1.style.background = barColors[1];
     bar2.style.background = barColors[0];
     bar3.style.background = barColors[0];
     fontColor.style.color = barColors[1];
   } else if (level == 2) 
   {
     bar1.style.background = barColors[2];
     bar2.style.background = barColors[2];
     bar3.style.background = barColors[0];
     fontColor.style.color = barColors[2];
   } else if (level == 1)
   {
     bar1.style.background = barColors[3];
     bar2.style.background = barColors[3];
     bar3.style.background = barColors[3];
     fontColor.style.color = barColors[3];
   }
 }
 
 
 function getParameter(name) {
			  var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");  
			  var r = window.location.search.substr(1).match(reg);  
			  if(r!=null)
			  { 
				  return unescape(r[2]);  
			  }
}

  function selectRegProduct(){
	  var product = getParameter("product");
	  if( product && (product=='popo')  ){
        document.getElementById('popooption').selected=true;
     }	
  }